package alchemist.model;

import java.util.Date;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable( identityType = IdentityType.APPLICATION, detachable = "true" )
public class DiscoveredElement 
{
    
    @PrimaryKey
    @Persistent
    private String elementId;
    @Persistent
    private Date   discovered;
    
    public DiscoveredElement() 
    {
    }
    
    public DiscoveredElement( String elementId, Date discovered ) 
    {
        super();
        this.elementId = elementId;
        this.discovered = discovered;
    }

    public String getElementId() 
    {
        return elementId;
    }
    
    public void setElementId( String elementId ) 
    {
        this.elementId = elementId;
    }
    
    public Date getDiscovered() 
    {
        return discovered;
    }
    
    public void setDiscovered( Date discovered ) 
    {
        this.discovered = discovered;
    }

    @Override
    public int hashCode() 
    {
        final int prime = 31;
        int result = 1;
        result = prime * result + ( ( elementId == null ) ? 0 : elementId.hashCode() );
        return result;
    }

    @Override
    public boolean equals( Object obj ) 
    {
        if ( this == obj )
            return true;
        if ( obj == null )
            return false;
        if ( getClass() != obj.getClass() )
            return false;
        DiscoveredElement other = ( DiscoveredElement ) obj;
        if ( elementId == null ) 
        {
            if ( other.elementId != null )
                return false;
        } 
        else if ( !elementId.equals( other.elementId ) )
            return false;
        return true;
    }

    @Override
    public String toString() 
    {
        return "DiscoveredElement [elementId=" + elementId + ", discovered=" + discovered + "]";
    }
    
}
